# ブックマーク登録済み確認APIクラス

require "rb/api.rb"

$KCODE = "UTF"

class CheckRegisteredAPI < API

    def initialize
        super
        @url = @cgi["url"]
        print flag_by_jsonp()
    end

    def flag_by_jsonp
        json_str = "{registered: false}"
        return attach_callback(json_str) unless check_auth()
        json_str = "{registered: true}" unless get_bookmarks().each do |i|
            break(false) if i["url"] == @url
        end
        return attach_callback(json_str)
    end

    def attach_callback(json_str)
        return 'Obm.checkRegisteredAPICallBack(' + json_str + ');'
    end
end

